package com.dashboard.task;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author xuxiao
 */
public class HotListTaskService {

//    @Resource
//    热榜mapper

    /** key:热榜预警方案 唯一key ;List 该热榜预警配置人员 */
    private ConcurrentMap<String, List > hotListTaskMap = new ConcurrentHashMap<>(32);

    ReentrantLock reentrantLock = new ReentrantLock();

    public void registerTask(String hotListWarningKey){
        if(hotListTaskMap.isEmpty()){
//            查询数据库数据 TODO
        }
//        查询该 key的数据
        reentrantLock.lock();
        try{
            hotListTaskMap.putIfAbsent(hotListWarningKey,null);
        }finally {
            reentrantLock.unlock();
        }
    }

    public ConcurrentMap<String, List > getHotListTaskMap(){
        return hotListTaskMap;
    }



}
